package com.yzz.shopping.restapi.controller;

import java.util.concurrent.CompletableFuture;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.gson.Gson;
import com.sixby.domain.entity.Order;
import com.yzz.shopping.domain.service.ShoppingService;

@RestController
@RequestMapping("/order")
public class OrderRestController {
    private static Logger logger = LoggerFactory.getLogger(OrderRestController.class);

    @Autowired
    private ShoppingService orderService;

    @RequestMapping(value="/{id}")
    public CompletableFuture<String> fnidById(@PathVariable String id) {
        return CompletableFuture.supplyAsync(() -> {
            Order order = orderService.findById(id);
            return new Gson().toJson(order);
        });
    }

}
